Repository navigation
test(studio): the edit-accuracy bench reads what a person ends with after sealed saves and undos - #8475
Conversation
…s last edit has saved A sealed press made while the previous save is out waits, then replays and saves. The sequence bench read the file once its write count was met, which one gesture writing twice can reach before the last gesture saves, so that edit looked lost. Studio now says on the page while an edit saves, and the bench also waits for that and for no waiting press, two frames in a row.
…d records how long it took
…m when Studio is idle
…its-for-held-press
Edit accuracy: accurate 271 (base branch 271), smooth 58 of thoseThe gate passes. Quarantined, measured but not gated (0) Unstable (1)
|
jrusso1020
left a comment
There was a problem hiding this comment.
Requesting changes at 87668e85, for one item: a new test in this PR is timing-flaky, and that turns the required Flake gate red.
settle.test.mjs, "says how long until the first of the clear reads, the undo's time to show", waits two 10 ms setTimeout frames and asserts ms >= 20. Node timers can fire about 1 ms early against the wall clock. Under the gate's CPU contention, 1 of 10 runs got expected 19 to be greater than or equal to 20 (settle.test.mjs:311, Flake gate job 137157040454).
Fix: have the test measure with an injected clock or fake timers, or assert a margin (e.g. >= 18) together with an upper bound that still tells "two frames" from "one frame". Then re-run the Flake gate.
The rest reviewed clean:
studioPendingEdits.tsmirrorsisStudioEditSaving()wherever either set changes.restedForrequires two clear reads in a row, and throws with a reason after its timeout.- The bench waits after the write count and after each undo.
- The "fails without the fix:" tests are named.
Need ✅ · Size ✅ · Reuse ✅ · Simpler ✅ · Structure ✅
Risk: low. The PR is test and bench code, plus one unstyled page attribute. The only blocker is this flake in the PR's own test.
— Rames (hf-review)
jrusso1020
left a comment
There was a problem hiding this comment.
Approving at aca81b37. My change request at 87668e85 is resolved.
restedFornow takes an injectednow(defaulting toDate.now).- The settle tests drive a fake clock that each frame advances by 10 ms, so "the undo's time to show" asserts an exact
20with no wall-clock sleeps. That removes the 19-vs-20 flake under contention. - The rest of the delta threads
nowthrough. Production calls keep theDate.nowdefault. The previously reviewed parts are unchanged.
Need ✅ · Size ✅ · Reuse ✅ · Simpler ✅ · Structure ✅
Risk: low. Test and bench code only.
— Rames (hf-review)
What
The edit-accuracy bench's sequences now read what a person ends up with:
Studio says on the page while an edit is saving (
data-studio-edits-saving), the same way it already saysdata-preview-changing. Each undo step also records two times:shownMs: when the box first moved;restMs: when Studio went idle.Why
In a sealed preview, edits and undos reach the page later than in a plain one, and the sequence bench read too early in two places.
1. The end of a sequence. A press made while the previous gesture's save is still out waits for that save, then replays and saves itself. Before reading, the bench waited for its write count to reach the number of saving steps, and for no press waiting. Both can pass before the last gesture saves:
So the bench read the file without the last edit, and the edit looked lost. With the server's write trace for
seqheldtwice-tlhold-px-r0-root-z100, sealed:2. After an undo. The bench pressed Ctrl+Z, waited one frame, then pressed the box's centre for the next drag.
sequndo-none-pct-r0-nested-z100, the bench pressed where the box was before the undo. Studio held the press until the undo showed, as it does for any press while the preview changes, found nothing under it, and the drag never started. That's the 12-248 px "jump" those cases reported.shownMsis the time during which a person still sees the old box, so it's the number to compare between sealed and plain.Related work
Refs #7846 (Studio's preview sealed by default): its edit-accuracy gate flagged these sequences as lost edits, lost undos and jumps.
How
studioPendingEdits.ts:isStudioEditSaving()(pending edits and shown undo/redo restores) is mirrored onto the page asdata-studio-edits-saving, updated wherever either set changes.sequences.mjs:restedFor(busy, frame)waits until nothing is busy for two frames in a row and returns the ms until the first clear read. It throws after 20 s.shownMsandrestMs.Plain sequences now also wait for each undo's save before their next press (about 0.7 s at p50 on Linux), where they used to press one frame after Ctrl+Z.
Results
The 13 cases the sealed gate flagged for undo, reload or a jump: Linux, 3 jobs, sealed and plain, on main plus the open sealed fixes, with the redo-box fix from #8462.
Each of the 13 failed sealed at least once on the gate before this PR. With it:
Passing sealed in every run:
seqheldtwice-tlhold-px-r0-root-z100(end-of-sequence wait);sequndo-none-{center,pct,px}-r0-nested-z100(undo wait);resize-none-px-r0-root-z100(fix(studio): an undo or redo that adds a sealed page's first edit stays in place #8462's redo box);seqresize-none-center-r0-root-z100.resize-spin-px-r0-root-z100-{after,mid}pass in 2 of 3 runs; the third failed drop and reload on the same run, which I haven't rooted.Still failing sealed and passing plain, with their own roots to find:
seqfastkeys-none-px-r0-root-z100;seqheldtwice-tlhold-px-r0-nested-z100;textselect-none-px-r0-root-z100;seqplainkeys-none-{center,pct}-r0-root-z100.Drag-follow (
tracking,teleport) fails sealed in most cases; that's separate work and this PR doesn't change it.No visible change
Studio gains one attribute on its root element while an edit saves, which nothing styles; the rest is bench code.
Test plan
fails without the fix:
studioPendingEdits.test.ts:settle.test.mjs:studioPendingEdits.test.tsplus the wholetests/e2e/edit-accuracy/folder (14 files, 157 tests) pass three runs in a row on Linux. Pre-commit (format, lint, fallow, typecheck) passes.